#!/bin/bash
set -e  # 出错时终止脚本

export BOOST_INCLUDE_ROOT=/root/work/boost-1.88.0
export BOOST_LIB_X64_DEBUG_ROOT=/root/work/boost-1.88.0/stage/Linux/ARM64/Debug/lib
export BOOST_LIB_X64_RELEASE_ROOT=/root/work/boost-1.88.0/stage/Linux/ARM64/Release/lib

# 创建输出目录
echo 创建输出目录
mkdir -p ./include/boost
mkdir -p ./lib/linux/Debug
mkdir -p ./lib/linux/Release

# 复制头文件
echo 复制头文件
# Windows下已经复制了头文件
#cp -r ${BOOST_INCLUDE_ROOT}/boost/* ./include/boost
target_dir="./include/boost/"
if [ -d "$target_dir" ] && [ "$(ls -A "$target_dir")" ]; then
    echo "Windows下已经复制了头文件，跳过复制。"
else
    mkdir -p "$target_dir"
    cp -r ${BOOST_INCLUDE_ROOT}/boost/* "$target_dir"
    echo "完成复制头文件。"
fi

# 复制linux Debug库
echo 复制linux Debug库
cp -d ${BOOST_LIB_X64_DEBUG_ROOT}/libboost_filesystem.so* ./lib/linux/Debug
cp -d ${BOOST_LIB_X64_DEBUG_ROOT}/libboost_container.so* ./lib/linux/Debug
cp -d ${BOOST_LIB_X64_DEBUG_ROOT}/libboost_log.so* ./lib/linux/Debug
cp -d ${BOOST_LIB_X64_DEBUG_ROOT}/libboost_log_setup.so* ./lib/linux/Debug
cp -d ${BOOST_LIB_X64_DEBUG_ROOT}/libboost_thread.so* ./lib/linux/Debug
cp -d ${BOOST_LIB_X64_DEBUG_ROOT}/libboost_atomic.so* ./lib/linux/Debug
cp -d ${BOOST_LIB_X64_DEBUG_ROOT}/libboost_json.so* ./lib/linux/Debug
cp -d ${BOOST_LIB_X64_DEBUG_ROOT}/libboost_locale.so* ./lib/linux/Debug
cp -d ${BOOST_LIB_X64_DEBUG_ROOT}/libboost_chrono.so* ./lib/linux/Debug

# 复制linux Release库
echo 复制linux Release库
cp -d ${BOOST_LIB_X64_RELEASE_ROOT}/libboost_filesystem.so* ./lib/linux/Release
cp -d ${BOOST_LIB_X64_RELEASE_ROOT}/libboost_container.so* ./lib/linux/Release
cp -d ${BOOST_LIB_X64_RELEASE_ROOT}/libboost_log.so* ./lib/linux/Release
cp -d ${BOOST_LIB_X64_RELEASE_ROOT}/libboost_log_setup.so* ./lib/linux/Release
cp -d ${BOOST_LIB_X64_RELEASE_ROOT}/libboost_thread.so* ./lib/linux/Release
cp -d ${BOOST_LIB_X64_RELEASE_ROOT}/libboost_atomic.so* ./lib/linux/Release
cp -d ${BOOST_LIB_X64_RELEASE_ROOT}/libboost_json.so* ./lib/linux/Release
cp -d ${BOOST_LIB_X64_RELEASE_ROOT}/libboost_locale.so* ./lib/linux/Release
cp -d ${BOOST_LIB_X64_RELEASE_ROOT}/libboost_chrono.so* ./lib/linux/Release

echo "boost库复制完成！"
echo "库文件路径: ${PWD}/lib/linux/{Debug,Release}"
echo "头文件路径: ${PWD}/include/boost"